//============================================================================
// Name        : problem183.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cmath>
#define E (2.7182818284590452353602874713526624977572470937L )
using namespace std;

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

int maxProduct(double n) {
	int f = floor(n/E);
	if (pow((double)(f+1)/f, f) > n/(f+1)) return f/gcd(n, f);
	return (f+1)/gcd(n, f+1);
}

bool terminatDec(int den) {
	while(den%2 == 0) {
		den /= 2;
	}

	while(den%5 == 0) {
		den /= 5;
	}
	if (den == 1) return true;
	return false;
}

int main() {
	long int sumD = 0;
	for(int n = 5; n <= 10000; n++) {
		if (terminatDec(maxProduct(n))) sumD -= n;
		else sumD += n;
	}
	cout << sumD<<endl; // prints !!!Hello World!!!
	return 0;
}
